from ast import List


class Solution:
    def search(self, nums: List[int], target: int) -> int:
        left = 0
        right = len(nums)-1
        while left<=right and nums[left]<target:
            left+=1
        
        while left<=right and nums[right]>target:
            right -=1
        return right-left+1
